from distutils.core import setup
from distutils.extension import Extension
import os
import os.path
import glob

# Author: Patrick Farrell
# patrick.farrell06@imperial.ac.uk

def MakeExtension(directory):
  try:
    os.stat(os.path.join("bindings", directory, "All_files_at_once.cpp"))
    files = [os.path.join("bindings", directory, "All_files_at_once.cpp")]
  except OSError:
    files = glob.glob(os.path.join("bindings", directory, "*.cpp"))

  curdir = os.path.abspath(os.curdir)

  ext = Extension(
      "CGAL/%s" % directory,
      files,
      include_dirs=["../..", curdir],
      libraries=["CGAL", "boost_python", "gmp", "mpfr"],
      define_macros=[('CGAL_DONT_USE_LAZY_KERNEL', None)]
      )
  return ext

directories = [directory for directory in os.listdir("bindings") if os.path.isdir(os.path.join("bindings", directory)) and directory != ".svn"]
extensions = [MakeExtension(directory) for directory in directories]

setup(
      name='CGAL-Python',
      version='0.9',
      description="Python bindings for the Computational Geometry Algorithms Library",
      author = "CGAL team",
      author_email = "patrick.farrell06@imperial.ac.uk",
      url = "http://cgal-python.gforge.inria.fr/",
      packages=["CGAL"],
      package_dir={"CGAL": "cgal_package/CGAL"},
      ext_modules=extensions,
     )
